package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.logic.activity.biaoju.BiaoJuConfig;
import com.yanqu.road.logic.activity.zhenhuan.ZhenHuanFirstProcessConfig;
import com.yanqu.road.logic.activity.zhenhuan.ZhenHuanSecondProcessConfig;
import com.yanqu.road.server.manger.activity.biaoju.BiaoJuConfigMgr;
import com.yanqu.road.server.manger.activity.zhenhuan.ZhenHuanConfigMgr;
import com.yanqu.road.utils.date.DateHelper;

import java.util.ArrayList;
import java.util.List;

public class BiaoJuRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        BiaoJuConfig config = BiaoJuConfigMgr.getConfig();
        if (config != null) {
            long recycleTime = config.getActivityInfo().getEndShowTime() * 1000L + 5 * DateHelper.MINUTE_MILLIONS;
            //快马加鞭、刷镖令均在活动后直接清空
            int speedupGoodsId = config.getSpeedupGoodsId();
            List<String> paramList = new ArrayList<>();
            ActivityItemRecycleMgr.addRecycleItemData(speedupGoodsId, config.getActivityInfo().getType(), 2, recycleTime, paramList);

//            int refreshGoodsId = config.getRefreshGoodsId();
//            ActivityItemRecycleMgr.addRecycleItemData(refreshGoodsId, config.getActivityInfo().getType(), 2, recycleTime, paramList);
        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.BiaoJu.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        int recycleType = data.getRecycleType();
        if (recycleType == 2) {
            UserBagItem item = getUserBagItem(userId, data.getItemId());
            if (item != null && item.getNum() > 0) {
                removeItem(item);
            }
        }
    }
}
